﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace log4net.WebTest
{
    public class TestObject
    {
        public int intData { get; set; }
        public float floatData { get; set; }
        public double doubleData { get; set; }
        public decimal decimalData { get; set; }

    }
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            var threadId = Thread.CurrentThread.ManagedThreadId;
            ILog logger = LogManager.GetLogger(typeof(Default));

            logger.Info("{\"d1\":1,\"d2\":2.0, \"d3\":3.123 }");
            logger.Error("我错了", new Exception("I'm wrong!"));

            return;

            var sw = new Stopwatch();
            sw.Start();
        //    Parallel.For(0, 10, (index) => {

                for (var i = 0; i < 200; i++)
                {
                    logger.Debug(new TestObject
                    {
                        intData = 12345,
                        floatData = 12345,
                        doubleData = 12345,
                        decimalData = 12345
                    });
                    logger.Warn(new TestObject
                    {
                        intData = 12345,
                        floatData = 12345.12345f,
                        doubleData = 12345.12345,
                        decimalData = 12345.12345m
                    });
                    logger.Info(new { d1 = 1, d2 = 2.0, d3 = 3.123m });
                    logger.Fatal("this Fatal msg");

                    try
                    {
                        var n = 0;
                        var j = 5 / n;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("this Error msg,中文测试", ex);
                    }
                }
       //     });
            sw.Stop();
            Response.Write(sw.ElapsedMilliseconds);
            Response.Write("|");
            Response.Write(sw.Elapsed);
        }
    }
}